package com.example.demo.service;

import com.example.demo.mapper.ArticleMapper;
import com.example.demo.model.ArticleInfo;
import com.example.demo.model.CommentInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleService {
    @Resource
    private ArticleMapper articleMapper;

    public int getArtCountByUid(Integer uid) {
        return articleMapper.getArtCountByUid(uid);
    }

    public List<ArticleInfo> getMyList(Integer uid) {
        return articleMapper.getMyList(uid);
    }

    public int del(Integer id, Integer uid) {
        return articleMapper.del(id, uid);
    }

    public ArticleInfo getDetail(Integer id) {
        return articleMapper.getDetail(id);
    }

    public int incrRCount(Integer id) {
        return articleMapper.incrRCount(id);
    }

    public int add(ArticleInfo articleInfo) {
        return articleMapper.add(articleInfo);
    }

    public int update(ArticleInfo articleInfo) {
        return articleMapper.update(articleInfo);
    }

    public List<ArticleInfo> getListByPage(Integer pSize, Integer offSize) {
        return articleMapper.getListByPage(pSize, offSize);
    }

    public int getArtCount() {
        return articleMapper.getArtCount();
    }

    /**
     * 保存草稿
     *
     * @param articleInfo
     * @return
     */
    public int draft(ArticleInfo articleInfo) {
        return articleMapper.draft(articleInfo);
    }

    public List<ArticleInfo> getListDraft(Integer uid) {
        return articleMapper.getListDraft(uid);
    }

    public List<CommentInfo> getCommentListByArtId(Integer artid) {
        return articleMapper.getCommentListByArtId(artid);
    }

    public int upComment(CommentInfo commentInfo) {
        return articleMapper.upComment(commentInfo);
    }
}
